提供在边缘端上新建规则、根据ID查询规则详情、编辑规则、根据ID删除规则、对规则的分页查询的功能。
功能描述:提供新建规则的功能,入参为规则具体内容,返回新增结果。
POST /api/v1/rules
Body:
Name | Type | Description | Required |
---|---|---|---|
name | string | 规则名 | Yes |
conditions | struct[] | 触发器结构体数组 | No (conditions和timeTrigger中至少必填一个) |
timeTrigger | string | 时间触发器 支持cron表达式(0 0 3,18 ? ) | No (conditions和timeTrigger中至少必填一个) |
actions | struct[] | 执行设备信息结构体数组 | No (actions和exportClientId中至少必填一个) |
ruleType | int | 规则类型,2-kubeedge | Yes |
exportClientId | int | 消息路由客户端ID | No (actions和exportClientId中至少必填一个) |
conditions的子对象结构体:
Name | Type | Description | Required |
---|---|---|---|
productId | int | 触发产品ID | Yes |
didList | int[] | 触发设备ID,空数组则代表该产品下的所有设备 | No(didList和labelId二者传其一) |
parameter | string | 触发设备属性名(定义功能时添加的属性名) | Yes |
operation | string | 触发设备判定符号(目前支持:> ; >= ; == ; < ; <= ; !=)(注:string,bool,byte只支持 == 与 != ) | Yes |
operand | 功能属性值类型 | 阈值(bool值写成true或者false,int写成数字) | Yes |
labelId | int | 分组ID | No(didList和labelId二者传其一) |
actions的子对象结构体:
Name | Type | Description | Required |
---|---|---|---|
productId | int | 执行产品ID | Yes |
deviceId | int | 执行设备ID | Yes |
identifier | string | 需执行的属性名(具有写权限的属性) | Yes |
value | 任意类型 | 值(bool值写成true或者false,int写成数字) | Yes |
Body example:
Body中含有actions和conditions的情况:
{
"actions": [
{
"deviceId": 10237739,
"identifier": "bbee",
"productId": 100567,
"value": 3
}
],
"conditions": [
{
"didList": [
10237739
],
"operand": "2",
"operation": "!=",
"parameter": "bbee",
"productId": 100567
}
],
"name": "stringw2111",
"ruleType": 2
}
Body中含有timeTrigger和actions的情况:
{
"timeTrigger": "0 0 3,18 * * ?",
"actions": [
{
"deviceId": 10237739,
"identifier": "bbee",
"productId": 100567,
"value": 3
}
],
"name": "strrringw2111",
"ruleType": 2
}
Body中含有exportClientId和conditions的情况:
{
"exportClientId": 10214,
"conditions": [
{
"didList": [
10237739
],
"operand": "2",
"operation": "!=",
"parameter": "bbee",
"productId": 100567
}
],
"name": "strrringw2f111",
"ruleType": 2
}
cURL example:
Body中含有actions和conditions的情况:
curl --location --request POST '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/rules?accessKeyId={accessKeyId}&signature={signature}&signatureNonce=646' \
--header 'platform: 3' \
--header 'projectId: {projectId}' \
--header 'Content-Type: application/json' \
--data-raw '{
"actions": [
{
"deviceId": 10237739,
"identifier": "bbee",
"productId": 100567,
"value": 3
}
],
"conditions": [
{
"didList": [
10237739
],
"operand": "2",
"operation": "!=",
"parameter": "bbee",
"productId": 100567
}
],
"name": "stringw2111",
"ruleType": 2
}'
Body中含有timeTrigger和actions的情况:
curl --location --request POST '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/rules?accessKeyId={accessKeyId}&signature={signature}&signatureNonce=646' \
--header 'platform: 3' \
--header 'projectId: {projectId}' \
--header 'Content-Type: application/json' \
--data-raw '{
"timeTrigger": "0 0 3,18 * * ?",
"actions": [
{
"deviceId": 10237739,
"identifier": "bbee",
"productId": 100567,
"value": 3
}
],
"name": "strrringw2111",
"ruleType": 2
}'
Body中含有exportClientId和conditions的情况:
curl --location --request POST '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/rules?accessKeyId={accessKeyId}&signature={signature}&signatureNonce=646' \
--header 'platform: 3' \
--header 'projectId: {projectId}' \
--header 'Content-Type: application/json' \
--data-raw '{
"exportClientId": 10214,
"conditions": [
{
"didList": [
10237739
],
"operand": "2",
"operation": "!=",
"parameter": "bbee",
"productId": 100567
}
],
"name": "strrringw2f111",
"ruleType": 2
}'
Response:
Name | Type | Description |
---|---|---|
data | int | 新建的规则ID |
Response example:
{
"data": "8ae491be7096bd2301709a46d7170009",
"success": true,
"code": 0,
"msg": null
}
功能描述:提供根据ID查询规则详情的功能,返回规则详情。
GET /api/v1/rules/{ruleId}
Path:
Name | Type | Description | Required |
---|---|---|---|
ruleId | string | 规则的ID | Yes |
cURL example:
curl --location --request GET '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/rules/{ruleId}?accessKeyId={accessKeyId}&signature={signature}&signatureNonce=646' \
--header 'platform: 3' \
--header 'projectId: {projectId}'
Response data:
Name | Type | Description |
---|---|---|
id | string | 规则ID |
name | string | 规则名称 |
userId | long | 用户ID |
userName | long | 用户名称 |
timeTrigger | string | 时间触发器,支持cron表达式 |
conditions | struct[] | 触发器结构体数组 |
actions | struct[] | 执行设备信息结构体数组 |
subscription | string[] | 接收人邮箱列表 |
mailServerId | string | 邮箱服务器ID |
mailServerName | string | 邮箱服务器名称 |
mailPatternId | string | 邮件模板ID |
mailPatternName | string | 邮件模板名称 |
export | boolean | 是否推送到export client |
exportClientId | int | 消息路由客户端ID |
ruleType | int | 规则类型,2-kubeedge |
status | enum | 规则状态(0:禁用,1:启用) |
Response data conditions的子对象结构体:
Name | Type | Description |
---|---|---|
type | int | 条件类型(1:数据点条件 2:设备上线 3:设备下线 4:设备删除) |
productId | int | 触发产品ID |
didList | int[] | 触发设备ID列表 |
productName | string | 触发产品名称 |
nameList | string[] | 触发设备名称列表 |
protocolType | int | 协议类型 |
check | struct | 触发器详情 |
labelId | int | 分组ID |
string | 分组名 |
Response data check的子对象结构体:
Name | Type | Description |
---|---|---|
parameter | string | 触发设备属性名(定义功能时添加的属性名) |
operation | string | 触发设备判定符号(目前支持:> ; >= ; == ; < ; <= ; !=)(注:string,bool,byte只支持 == 与 != ) |
operand | 任意类型 | 阈值(bool值写成true或者false,int写成数字) |
type | int | 条件类型(1:数据点条件 2:设备上线 3:设备下线 4:设备删除) |
Response data actions的子对象结构体:
Name | Type | Description |
---|---|---|
productId | int | 执行产品ID |
deviceId | int | 执行设备ID |
identifier | string | 需执行的属性名(具有写权限的属性) |
value | 任意类型 | 值(bool值写成true或者false,int写成数字) |
type | int | 条件类型(1:数据点条件 2:设备上线 3:设备下线 4:设备删除) |
protocolType | int | 协议类型 |
deviceName | string | 执行设备名称 |
productName | string | 执行产品名称 |
Response example:
{
"success": true,
"code": 0,
"msg": null,
"data": {
"id": "8ae48daf7163309a0171ee0575150010",
"name": "string111",
"userId": "1bb9909ee93647df883b9043743a345d",
"userName": "liubo3",
"timeTrigger": null,
"conditions": [
{
"productName": "cdedd",
"productId": 100235,
"protocolType": 5,
"labelId": null,
"labelName": null,
"check": {
"parameter": "abcd",
"operation": "!=",
"operand": "true",
"type": 2
},
"type": 2,
"nameList": [
"crcr"
],
"didList": [
10000781
]
}
],
"filters": [],
"actions": [
{
"deviceId": 10000781,
"deviceName": "crcr",
"productName": "cdedd",
"productId": 100235,
"protocolType": 5,
"identifier": "abcd",
"value": "true",
"type": 2
}
],
"subscription": [],
"mailServerId": "",
"mailServerName": "",
"mailPatternId": "",
"mailPatternName": "",
"export": false,
"exportClientId": null,
"ruleType": 2,
"status": "DISABLED"
}
}
功能描述:更新规则的功能,入参为规则具体内容。
PUT /api/v1/rules/{ruleId}
Path:
Name | Type | Description | Required |
---|---|---|---|
ruleId | string | 规则的ID | Yes |
Body:
Name | Type | Description | Required |
---|---|---|---|
name | string | 规则名 | No |
conditions | struct[] | 触发器结构体数组 | No |
timeTrigger | string | 时间触发器 支持cron表达式(0 0 3,18 ? ) | No |
actions | struct[] | 执行设备信息结构体数组 | No |
conditions的子对象结构体:
Name | Type | Description | Required |
---|---|---|---|
productId | int | 触发产品ID | Yes |
didList | int[] | 触发设备ID,空数组则代表该产品下的所有设备 | No(didList和labelId二者传其一) |
parameter | string | 触发设备属性名(定义功能时添加的属性名) | Yes |
operation | string | 触发设备判定符号(目前支持:> ; >= ; == ; < ; <= ; !=)(注:string,bool,byte只支持 == 与 != ) | Yes |
operand | 功能属性值类型 | 阈值(bool值写成true或者false,int写成数字) | Yes |
labelId | int | 分组ID | No(didList和labelId二者传其一) |
actions的子对象结构体:
Name | Type | Description | Required |
---|---|---|---|
productId | int | 执行产品ID | Yes |
deviceId | int | 执行设备ID | Yes |
identifier | string | 需执行的属性名(具有写权限的属性) | Yes |
value | 任意类型 | 值(bool值写成true或者false,int写成数字) | Yes |
Body example:
{
"actions": [
{
"deviceId": 10237739,
"identifier": "bbee",
"productId": 100567,
"value": 3
}
],
"conditions": [
{
"didList": [
10237739
],
"operand": "2",
"operation": "!=",
"parameter": "bbee",
"productId": 100567
}
],
"name": "stri44ngw2111",
"ruleType": 2
}
cURL example:
curl --location --request PUT '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/rules/{ruleId}?accessKeyId={accessKeyId}&signature={signature}&signatureNonce=646' \
--header 'platform: 1' \
--header 'projectId: {projectId}' \
--header 'Content-Type: application/json' \
--data-raw '{
"actions": [
{
"deviceId": 10237739,
"identifier": "bbee",
"productId": 100567,
"value": 3
}
],
"conditions": [
{
"didList": [
10237739
],
"operand": "2",
"operation": "!=",
"parameter": "bbee",
"productId": 100567
}
],
"name": "stri44ngw2111",
"ruleType": 2
}'
Response example:
{
"data": null,
"success": true,
"code": 0,
"msg": null
}
功能描述:提供根据ID删除规则的功能,返回删除结果。
DELETE /api/v1/rules/{ruleId}
Path:
Name | Type | Description | Required |
---|---|---|---|
ruleId | string | 规则的ID | Yes |
cURL example:
curl --location --request DELETE '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/rules/{ruleId}?accessKeyId={accessKeyId}&signature={signature}&signatureNonce=646' \
--header 'platform: 3' \
--header 'projectId: {projectId}'
Response example:
{
"success": true,
"code": 0,
"msg": null,
"data": null
}
功能描述:提供对规则的分页查询功能,返回规则列表。
GET /api/v1/rules
Query:
Name | Type | Description | Required |
---|---|---|---|
pageSize | int | 分页大小 | Yes |
currentPage | int | 页码 | Yes |
name | string | 规则名 | No |
type | int | 规则类型,0-边缘端 | No |
cURL example:
curl --location --request GET '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/rules/{ruleId}?accessKeyId={accessKeyId}&signature={signature}&signatureNonce=646¤tPage={currentPage}&pageSize={pageSize}' \
--header 'platform: 3' \
--header 'projectId: {projectId}'
Response data:
Name | Type | Description |
---|---|---|
totalCount | int | 总数量 |
pageSize | int | 分页大小 |
currentPage | int | 页码 |
totalPage | int | 总页数 |
content | struct[] | 内容 |
Response data content的子对象结构体:
Name | Type | Description |
---|---|---|
id | string | 规则ID |
name | string | 规则名称 |
userId | long | 用户ID |
userName | long | 用户名称 |
timeTrigger | string | 时间触发器,支持cron表达式 |
conditions | struct[] | 触发器结构体数组 |
actions | struct[] | 执行设备信息结构体数组 |
subscription | string[] | 接收人邮箱列表 |
mailServerId | string | 邮箱服务器ID |
mailServerName | string | 邮箱服务器名称 |
mailPatternId | string | 邮件模板ID |
mailPatternName | string | 邮件模板名称 |
export | boolean | 是否推送到export client |
exportClientId | int | 消息路由客户端ID |
ruleType | int | 规则类型,2-kubeedge |
status | enum | 规则状态(0:禁用,1:启用) |
Response data conditions的子对象结构体:
Name | Type | Description |
---|---|---|
type | int | 条件类型(1:数据点条件 2:设备上线 3:设备下线 4:设备删除) |
productId | int | 触发产品ID |
didList | int[] | 触发设备ID列表 |
productName | string | 触发产品名称 |
nameList | string[] | 触发设备名称列表 |
protocolType | int | 协议类型 |
check | struct | 触发器详情 |
int | 分组ID | |
string | 分组名 |
Response data check的子对象结构体:
Name | Type | Description |
---|---|---|
parameter | string | 触发设备属性名(定义功能时添加的属性名) |
operation | string | 触发设备判定符号(目前支持:> ; >= ; == ; < ; <= ; !=)(注:string,bool,byte只支持 == 与 != ) |
operand | 任意类型 | 阈值(bool值写成true或者false,int写成数字) |
type | int | 条件类型(1:数据点条件 2:设备上线 3:设备下线 4:设备删除) |
Response data actions的子对象结构体:
Name | Type | Description |
---|---|---|
productId | int | 执行产品ID |
deviceId | int | 执行设备ID |
identifier | string | 需执行的属性名(具有写权限的属性) |
value | 任意类型 | 值(bool值写成true或者false,int写成数字) |
type | int | 条件类型(1:数据点条件 2:设备上线 3:设备下线 4:设备删除) |
protocolType | int | 协议类型 |
deviceName | string | 执行设备名称 |
productName | string | 执行产品名称 |
Response example:
{
"success": true,
"code": 0,
"msg": "",
"data": {
"currentPage": 1,
"pageSize": 10,
"totalCount": 1,
"totalPage": 1,
"content": [
{
"id": "8ae48daf7163309a0171ee0575150010",
"name": "string111",
"userId": "1bb9909ee93647df883b9043743a345d",
"userName": "liubo3",
"timeTrigger": null,
"conditions": [
{
"productName": "cdedd",
"productId": 100235,
"protocolType": 5,
"labelId": null,
"labelName": null,
"check": {
"parameter": "abcd",
"operation": "!=",
"operand": "true",
"type": 2
},
"type": 2,
"nameList": [
"crcr"
],
"didList": [
10000781
]
}
],
"filters": [],
"actions": [
{
"deviceId": 10000781,
"deviceName": "crcr",
"productName": "cdedd",
"productId": 100235,
"protocolType": 5,
"identifier": "abcd",
"value": "true",
"type": 2
}
],
"subscription": [],
"mailServerId": "",
"mailServerName": "",
"mailPatternId": "",
"mailPatternName": "",
"export": false,
"exportClientId": null,
"ruleType": 2
}
]
}
}